import numpy as np


def rgb2y(img1, img2):

    img1 = img1.astype(np.float64)
    img2 = img2.astype(np.float64)
    y1 = img1[:, :, 0] * 0.257 + img1[:, :, 1] * 0.504 + img1[:, :, 2] * 0.098 + 16
    # cb1 = img1[:, :, 0] * (-0.148) + img1[:, :, 1] * (-0.291) + img1[:, :, 2] * 0.439 + 128
    # cr1 = img1[:, :, 0] * 0.439 + img1[:, :, 1] * (-0.368) + img1[:, :, 2] * (-0.071) + 128

    y2 = img2[:, :, 0] * 0.257 + img2[:, :, 1] * 0.504 + img2[:, :, 2] * 0.098 + 16

    # cb2 = img2[:, :, 0] * (-0.148) + img2[:, :, 1] * (-0.291) + img2[:, :, 2] * 0.439 + 128
    # cr2 = img2[:, :, 0] * 0.439 + img2[:, :, 1] * (-0.368) + img2[:, :, 2] * (-0.071) + 128
    return y1, y2
